package com.factory.iamp.service.impl;

import com.factory.iamp.dao.SapMapper;
import com.factory.iamp.pojo.Sap;
import com.factory.iamp.service.SapService;
import com.factory.iamp.utils.helper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(rollbackFor = Throwable.class)
public class SapServiceImpl implements SapService {
    @Resource
    SapMapper sapMapper;

    @Override
    public int Count(int lid) {
        return sapMapper.Count(lid);
    }

    @Override
    public List<Sap> ListPaged(PageHelper data, int lid) {
        return sapMapper.ListPaged(data.calOffset(), data.getLimit(), lid);
    }

    @Override
    public Sap findByOrderId(String OrderId, int lid) {
        return sapMapper.getSapByOrderId(OrderId, lid);
    }

    @Override
    public int findCount(String findstr, int lid) {
        return sapMapper.findCount(findstr, lid);
    }

    @Override
    public List<Sap> findByStr(PageHelper data, String str, int lid) {
        return sapMapper.findSap(str, lid, data.calOffset(), data.getLimit());
    }

    @Override
    public void addSap(int lid, String data) throws Throwable {
        Sap sap = new Sap(data);
        sapMapper.addSap(sap.getOrder_id(), lid, sap);
    }

    @Override
    public void addSap(int lid, Sap sap) throws Throwable {
        sapMapper.addSap(sap.getOrder_id(), lid, sap);
    }

    @Override
    public void delete(String order_id, int lid) {
        sapMapper.deleteSap(order_id, lid);
    }
}
